π€ feat: RLM Mode β kernel-first exclusive PTC posture with persistent kernel, context isolation, and continual-harness features - #3900
π€ feat: RLM Mode β kernel-first exclusive PTC posture with persistent kernel, context isolation, and continual-harness features#3900ThomasK33 wants to merge 204 commits into
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
π‘ Tip: Enable Workflows to automatically generate PRs for you. |
|
@codex review |
β¦inement journal, RLM mode experiment) Conductor for implementing prime-agent-inspired RLM/continual-harness features behind an opt-in RLM sub-experiment of PTC. Mirrors workflows/track1-implementation.js: per-phase implement -> gate+adversarial-review -> fix rounds -> dogfood.
β¦ code_execution RLM Mode is an opt-in sub-experiment of Programmatic Tool Calling (flat flag, gated on the PTC parent at call sites, nested under the PTC toggle in Settings, mirroring the Memory Hot Set precedent). When enabled with PTC and sandbox context, code_execution runs on the persistent per-workspace kernel mount: the guest vars namespace survives across calls/turns and restarts via snapshots, and the tool description advertises those kernel semantics. MUX_SANDBOX_PERSISTENT_MOUNTS=1 remains a dev/test override with unchanged behavior. With the experiment off (and env unset) behavior is byte-identical to before: fresh runtime per call and today's description. The rlm flag plumbs through the experiments path end to end: ExperimentsSchema (send options) -> aiService.streamMessage -> applyToolPolicyAndExperiments. Signed-off-by: Thomas Kosiewski <tk@coder.com>
β¦verified curl recipe) and note r1 landed
Every mutating memory command (create/str_replace/insert/delete/rename) and
every agent_skill_write/agent_skill_delete now appends exactly one
'refinement' durable event to the acting workspace's session journal
(sharedDurableEventJournal), carrying an inverse payload that byte-exactly
restores the prior file state. Prior contents over 4KB are offloaded to the
session blob store (BlobRef), mirroring hook-context. Evidence records
{workspaceId, toolName, toolCallId?, actor?}.
Always-on and purely additive: journaling failures never fail the tool
(log.debug + continue), read-only ops and failed mutations write no rows.
Cross-workspace caveat (v1): memory/skill files are global/project-scoped
while the journal is per-session; rows land in the acting workspace's log.
Signed-off-by: Thomas Kosiewski <tk@coder.com>
Standalone, always-on-by-usage gate memoizer: 'fingerprint' hashes HEAD sha + 'git diff HEAD' + sorted untracked-not-ignored files with content hashes; 'record <gate> <pass|fail>' and 'check <gate>' store/look up results in a JSON file inside the worktree-local git dir (git rev-parse --git-path), so records are never committed and never invalidate themselves. wait_pr_ready.sh integration was skipped intentionally: it has no local validation step (it only orchestrates remote Codex/review/CI gates), per the phase brief's conditional. Tests spawn the real script against hermetic temp git repos and cover stability, pass/fail round-trip, tracked-edit / untracked-file / staged-change invalidation, and corrupt-store self-healing. Signed-off-by: Thomas Kosiewski <tk@coder.com>
β¦-handle events
Under an RLM persistent mount, nested mux.* results and code_execution
return values whose JSON serialization exceeds 16KB stop entering the
model context: the model-visible record becomes {handle, preview, size}
(plus a follow-up hint for return values) while the full value stays in
the guest at vars.__hN (monotonic per scope via vars.__handleSeq, so it
snapshots/restores with vars), in the content-addressed blob store, and
in one result-handle durable event whose preview mirrors the
model-visible string exactly. Handle bytes retained in vars are capped
with oldest-first eviction (never the newest handle); the blob remains
the durable copy. RLM off / ephemeral runtimes are byte-identical to
today.
Signed-off-by: Thomas Kosiewski <tk@coder.com>
Signed-off-by: Thomas Kosiewski <tk@coder.com>
Signed-off-by: Thomas Kosiewski <tk@coder.com>
Signed-off-by: Thomas Kosiewski <tk@coder.com>
β¦escription) Signed-off-by: Thomas Kosiewski <tk@coder.com>
β¦ervice finalizeAgentTaskReport now invokes sandboxHostService.postTaskTerminalEvent (fire-and-forget, gated on no foreground waiters) so spawned-task completions reach the guest host-event queue in production β previously the hook had zero production callsites and mux.events() always drained empty. Regression tests cover both the posted-event and waiter-suppression branches. Signed-off-by: Thomas Kosiewski <tk@coder.com>
β¦h lineage listRefinements/rollbackRefinement make the r2 journal actionable: rollbacks apply the recorded inverse (inline or blob-backed) through atomic writes, journal their own refinement row with rollbackOf (so double inversion works), refuse already-rolled-back targets, refuse divergence (later overlapping rows, deleted/recreated files, content drift for rollback rows) unless forced, and confine every touched path to memory scope roots / skill directories with lexical + symlink escape checks that force can never override. Signed-off-by: Thomas Kosiewski <tk@coder.com>
β¦orce Signed-off-by: Thomas Kosiewski <tk@coder.com>
Assembled in toolAssembly from the sandbox context inside the PTC branch, so the tool only exists when RLM mode is on (nested under the PTC parent); with the experiment off the toolset β and thus every provider request β stays byte-identical. Force stays CLI-only: divergence overrides are a human call. Signed-off-by: Thomas Kosiewski <tk@coder.com>
β¦refinement_rollback Signed-off-by: Thomas Kosiewski <tk@coder.com>
β¦ memory to current session - P1: the later-rows divergence check now nets out rollback lineage: rows whose effect was itself rolled back are skipped, and live rollback chains conflict only when their parity re-applies an edit or rewinds past the target β so LIFO multi-edit unrolling works for model tool calls without force, while re-applied edits (rollback-of-rollback) still refuse. - P2: workspace-scope memory confinement resolves strictly to the current session's memory root (<sessionDir>/memory) instead of any session subdir under sessionsDir, closing the cross-workspace write leak. Signed-off-by: Thomas Kosiewski <tk@coder.com>
β¦tCode on undefined assignment) Signed-off-by: Thomas Kosiewski <tk@coder.com>
β¦action) Signed-off-by: Thomas Kosiewski <tk@coder.com>
β¦oundary copies, read-file tracking Signed-off-by: Thomas Kosiewski <tk@coder.com>
β¦rendering Signed-off-by: Thomas Kosiewski <tk@coder.com>
Signed-off-by: Thomas Kosiewski <tk@coder.com>
β¦est metadata, optional chain Signed-off-by: Thomas Kosiewski <tk@coder.com>
β¦tch + staleness guard) Signed-off-by: Thomas Kosiewski <tk@coder.com>
Signed-off-by: Thomas Kosiewski <tk@coder.com>
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 59b6d5fb98
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
β¦route (Codex r31) resolveDreamModelString's fallback tier read only legacy aiSettings, which updateAgentAISettings never rewrites β so a workspace whose current model is a per-agent private/gateway route could fall through a stale legacy model or the built-in direct-Anthropic default, shipping up to 160K chars of transcript-derived content off the selected route. Absent an explicit dream override (workspace dream bucket or global dream default β both explicit consent), fallbacks now derive from the same route-confined candidate list as branch summaries: the selected agent's model, other per-agent models, then the legacy model as a compatibility fallback.
|
@codex review |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a5f825c2b3
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
β¦dmission - refineRunner: neutralize embedded workspace_trajectory delimiter sequences before interpolation (branch-summary parity) so transcript content cannot close the data region and reach instruction level. - agentSession/historyService: persist family payload rows + trigger user row as ONE durable write (appendManyToHistory) β separate appends left a crash window that stranded an orphaned payload in history. - sandboxHostService: rebuild vars.__loadMeta as a fresh plain object each retention pass; a frozen/write-swallowing registry silently exempted new loads from the 4MiB managed cap. - agentSession: reserve edit turn admission (editAdmissionDepth in isBusy) across truncate + branch summary + row appends; a concurrent send could observe idle mid-edit and interleave rows. - refineService: hold a cross-process lockfile across apply (XUM_ALLOW_MULTIPLE_INSTANCES backends could double-apply a staged set), and gate /refine on the renderer's effective experiment flags riding the request (backend override persistence is async/best-effort).
|
@codex review |
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b1ec62404b
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
β¦ durability, usage-write drain, full-clear sandbox discard) - refineService: report failed staged edits on the record + audit row instead of classifying an all-failed apply as a successful no-op; never-executed skips (tool unavailable / schema-rejected) stay out of the attempted set and retain the staged set for retry; audit/proposal row appends propagate failure so the staged set is consumed only after the row durably lands - branchSummary: track usage writes abandoned by the deadline race and drain them in clearPendingBranchSummary so removal's usage rollup cannot miss a late write that would recreate the deleted session directory - workspaceService: full history clear and destructive non-compaction replace durably discard sandbox kernel state (same posture as resetContext)
|
Addressed all 4 round-33 findings in a5f825c..9066a7a:
Validation: @codex review |
β¦ unjournaled successes (Codex r33 follow-up) An unjournaled success (memory write succeeded, refinement-journal append failed) left no durable trace once the crash-resumed apply skipped the attempted edit with its in-pass counter at zero: recovery misreported the real, rollback-less mutation as a no-op and consumed the staged set. The staged file now persists succeededToolCallIds alongside the attempted set, and untrackedApplied derives from persisted successes minus journaled rows.
|
Addressed the fifth round-33 finding in 9066a7a..c24bfe7:
Also minimized the stale "Something went wrong" error comment and the security-review note that were blocking the Codex Comments check. Validation: @codex review |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c24bfe7212
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
β¦staging/apply cross-process lock, Anthropic-only assistant merge) - refineService/refineStaging: persist failedToolCalls (id + reason) in the per-edit progress rewrite and rebuild the record's failures from persisted outcomes, so a crash-resumed apply reports the approved edit's failure instead of misclassifying a no-op and consuming the staged set silently - refineService: staged-set replacement + proposal publication in runLocked now acquire the same cross-process refine-apply.lock as apply, so a /refine in one backend cannot be overwritten by a concurrent apply's stale staged snapshot spread under XUM_ALLOW_MULTIPLE_INSTANCES=1 - modelMessageTransform: the consecutive-assistant merge pass is gated to Anthropic (the only provider rejecting adjacent assistant rows) and now preserves original text parts verbatim so part-level providerOptions survive instead of being re-joined into one plain string
|
Addressed all 3 round-34 findings in c24bfe7..b141504:
Validation: @codex review |
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b141504f74
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
π‘ Codex Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: b141504f74
Only the user who started this review can view the report in Codex.
βΉοΈ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and youβre opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
β¦nt merge (Codex r35) History recorded with extended thinking can carry a signed-reasoning assistant row whose trailing text part is empty; merging a synthetic summary into it copied that empty block into the request, which Anthropic rejects. Both sides of the merge now drop empty text parts while preserving non-text parts (signed reasoning) and part-level providerOptions verbatim.
|
Addressed the round-35 finding in b141504..48392e0:
Validation: @codex review |
β¦th (Codex r35 security follow-up) A reset that failed AFTER writing its boundary but BEFORE its durable cleanup landed left the retry on the no-op branch (no provider-eligible rows after the boundary), reporting success while a restart could still restore pre-reset post-compaction carryover or kernel vars across the boundary. The no-op branch now re-runs both idempotent cleanup steps (pending-state unlink, sandbox discard) durable-or-Err before reporting noop.
|
Addressed the round-35 security follow-up in 48392e0..6db1250:
Note: the Validation: @codex review |
|
Codex Review: Didn't find any major issues. π Reviewed commit: βΉοΈ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with π. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
π‘ Codex Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: 6db12509e6
Only the user who started this review can view the report in Codex.
βΉοΈ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and youβre opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
β¦ (Codex r37 security) getLastMessages crosses reset boundaries and pages into the sealed archive, so after /clear --soft a pre-reset prompt injection could steer the staged proposal β durably appended AFTER the boundary and re-entering model-visible context, persisting to memory/skills on approval. The distillation read now uses getHistoryFromLatestBoundary + the provider context-boundary slice (tail-capped as before), timeline events get the same cutoff, and the approval-hash scan never crosses a reset backwards (pre-reset proposals fail closed; compaction remains crossable so pre-compaction proposals stay approvable).
|
Addressed the round-37 security finding in 6db1250..b08f29d:
Tests: prompt-confinement test (pre-reset injected row + pre-boundary timeline event excluded, post-reset rows + recent events included) and a pre-reset-proposal apply-refusal test. Validation: @codex review |
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b08f29db3b
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
β¦iguous timeline boundary, delimited timeline prompt data) - workspaceService: resetContext cancels + drains any in-flight refine pass before appending its boundary, so a pass distilling the pre-reset transcript cannot publish after the marker - refineService: boundary-identity recheck under the staging lock fails the pass closed when the latest context boundary changed between the history snapshot and publication (residual TOCTOU window) - refineService: timeline cutoff fails closed when the boundary row has no usable timestamp and uses a strictly-after comparison so same-millisecond pre-reset events are excluded - refineRunner: timeline text is wrapped in its own <workspace_timeline> untrusted-data block with both delimiter families neutralized, so chat-copied digests cannot sit at instruction level or forge a trajectory region
|
Addressed all 3 round-38 findings in b08f29d..3dea281:
Validation: @codex review |
Summary
Adds RLM Mode β an opt-in, kernel-first execution posture for PTC inspired by PrimeIntellect's prime-agent architecture β plus the continual-harness features around it (refinement journal with rollback,
/refinetrajectory distillation, family messaging, branch summarization, compaction improvements) and a measurement harness (shux rlm-eval) that every major design decision in this PR was validated against.With the RLM experiment off, behavior is byte-identical to main (pinned by composition tests and
replay-verifyon live sessions). With it on,code_executionbecomes the primary tool backed by a persistent per-workspace QuickJS kernel.Background
Research into prime-agent (which posted strong vendor-reported eval results) identified two core ideas worth porting: a single persistent code kernel where in-kernel data never transits model context, and a self-modifying harness with journaled, reversible edits. Mux's Track 1 foundation (journal kit, durable events, sandbox host, replay harness β #3865/#3872) provided the substrate; this PR is "Track 2" built on it, implemented via the phased conductor workflow in
workflows/track2-rlm-implementation.js(per-phase quality gates, adversarial review, live dogfooding).Implementation
RLM kernel (phases r1, r4, r5, r12):
rlm-modeexperiment, nested under PTC; exclusive-only β enabling it forces the kernel-first narrowed toolset (supplement-mode RLM measured ~2x flat cost and was removed)varssurvives calls/turns/restarts via journaled snapshotsshux.*results never enter model context (compact{tool, ok, bytes}summaries); the model's channels are its return value (offloaded via handles >16KB), capped console output, andvarsshux.load({path, key}): host-side bulk file ingestion straight intovars(record shows{key, bytes, lines, preview}only)shux.task_spawn+shux.events(): fire-and-forget sub-agents with admission handles, asyncify-safe event drainContinual harness (r2, r6, r11):
refinementdurable event (blob-backed inverses)rollbackOflineage:shux run debug refinementsCLI + RLM-gatedrefinement_rollbacktool/refine: bounded trajectory-distillation pass (dream-agent machinery) applying smallest evidence-backed edits, journaled and reversibleAgent ops (r3, r7, r8, r9):
task_message_parent/task_message_sibling(RLM stamped on task records at spawn; strict same-parent scoping; server-side labels)scripts/gate_fingerprint.shverification-loop memoizerMeasurement (
scripts/rlm-eval/,make rlm-eval): scenario x config x seed A/B runner extracting mechanical metrics (tokens, cost, wall time, peak context, vars adoption, batch factor, compactions) from session artifacts.Validation
varsadoption 15/16replay-verifyPASS (evidence in the workflow run reports)mux.*alias intactRisks
toolAssembly,code_execution, compaction paths (RLM-gated), task spawn paths (flag stamping).shux.loadmaterializes large files (latent pressure on multi-MB corpora), and one sonnet seed still fragments batching./refineauto-applies edits (no approval UI in v1) β mitigated by journal + rollback + immutable-base guard rails.Pains
mux->shuxrename on main required conflict resolution across the kernel commits (namespace, type-generator identifiers, description text).Generated with
muxβ’ Model:anthropic:claude-fable-5β’ Thinking:xhighβ’ Cost:$763.80